/***************************************************************************
 *   Copyright (C) 2012 Ricardo Fernandes - All Rights Reserved            *
 *   Email: rjf@dcc.fc.up.pt or rikardojfernandez@gmail.com                *
 *                                                                         *
 *   This file is part of the project that integrates VNS and OMNET++      *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

#ifndef VNS_OMNETNETWORKMODULE_H_
#define VNS_OMNETNETWORKMODULE_H_

#include <vns/networkmodule.h>
#include <vns/lock.h>
#include <map>

class VNSEnvir;
class cSimulation;
class cConfigurationEx;
class BaseConnectionManager;
class cModule;
class cModuleType;
class VNSMobility;


namespace vns {

class OmnetNetworkModule : public NetworkModule {
public:
	OmnetNetworkModule(int argc, char** argv);
	virtual ~OmnetNetworkModule();

public:
	void onSimulationStart(const Simulator* simulator);
	void onSimulationStep(const Simulator* simulator);
	void onSimulationStop(const Simulator* simulator);
	void onVehicleCreated(const Simulator* simulator, Vehicle* vehicle);
	void onVehicleRemoved(const Simulator* simulator, Vehicle* vehicle);


	typedef std::map<vns::Vehicle*, VNSMobility*> MobilityModules;
	MobilityModules mobilityModules;
private:



	cSimulation *sim;
	VNSEnvir *env;
	cConfigurationEx* configObject;
	BaseConnectionManager* connectionManager;
	cModule* net;
	char* networkName;
	char* vehicleModuleTypeName;
	cModuleType* vehicleModuleType;
	cModuleType* mobilityModuleType;
	Lock lock;
	int nVehicles;

public:

	MobilityModules* getMobilityModules(){ return &mobilityModules; };

};

}

#endif
